/*
 * DIOC1.h
 *
 *  Created on: 16/11/2012
 *      Author: Richard
 */

#ifndef DIOC1_H_
#define DIOC1_H_

#include <msp430.h>
#include "DIOCE.h"
#include "../../cdef.h"

#define MSP430_PIN_PA00            0
#define MSP430_PIN_PA01            1
#define MSP430_PIN_PA02            2
#define MSP430_PIN_PA03            3
#define MSP430_PIN_PA04            4
#define MSP430_PIN_PA05            5
#define MSP430_PIN_PA06            6
#define MSP430_PIN_PA07            7
#define MSP430_PIN_PA08            8
#define MSP430_PIN_PA09            9
#define MSP430_PIN_PA10            10
#define MSP430_PIN_PA11            11
#define MSP430_PIN_PA12            12
#define MSP430_PIN_PA13            13
#define MSP430_PIN_PA14            14
#define MSP430_PIN_PA15            15

#define MSP430_PIN_PB00            16
#define MSP430_PIN_PB01            17
#define MSP430_PIN_PB02            18
#define MSP430_PIN_PB03            19
#define MSP430_PIN_PB04            20
#define MSP430_PIN_PB05            21
#define MSP430_PIN_PB06            22
#define MSP430_PIN_PB07            23
#define MSP430_PIN_PB08            24
#define MSP430_PIN_PB09            25
#define MSP430_PIN_PB10            26
#define MSP430_PIN_PB11            27
#define MSP430_PIN_PB12            28
#define MSP430_PIN_PB13            29
#define MSP430_PIN_PB14            30
#define MSP430_PIN_PB15            31

#define MSP430_PIN_PC00            32
#define MSP430_PIN_PC01            33
#define MSP430_PIN_PC02            34
#define MSP430_PIN_PC03            35
#define MSP430_PIN_PC04            36
#define MSP430_PIN_PC05            37
#define MSP430_PIN_PC06            38
#define MSP430_PIN_PC07            39

typedef struct
{
   uint16 u16Input;                 /* 00h */
   uint16 u16Output;                /* 02h */
   uint16 u16Direction;             /* 04h */
   uint16 u16ResistorEnable;        /* 06h */
   uint16 u16DriveStrength;         /* 08h */
   uint16 u16PortSelect;            /* 0Ah */
   uint16 u16Reserved[6];           /* 0Ch - 16h */
   uint16 u16InterruptEdgeSelect;   /* 18h */
   uint16 u16InterruptEnable;       /* 1Ah */
   uint16 u16InterruptFlag;         /* 1Ch */
   uint16 :16;                      /* 1Eh */
} MSP430_tstDIO;

typedef struct
{
   MSP430_tstDIO stPort[3];
} DIO_tstGPIO;

#define MSP430_GPIO                 (*((volatile DIO_tstGPIO*)__MSP430_BASEADDRESS_PORTA_R__))

void DIO_vReset( void );
void DIO_vSetDirection( DIO_tenPinName enPin, DIO_tenDataDirection enDirection );
void DIO_vSetOutput( DIO_tenPinName enPin, DIO_tenLogicLevel enLevel );
void DIO_vToggleOutput( DIO_tenPinName enPin );
DIO_tenLogicLevel DIO_enGetInput( DIO_tenPinName enPin );
void DIO_vSetResistor( DIO_tenPinName enPin, bool boEnable );
void DIO_vSetDriveStrength( DIO_tenPinName enPin, DIO_tenDriveStrength enDriveStrength );
void DIO_vSetPortSelect( DIO_tenPinName enPin, DIO_tenPortSelect enPortSelect );
void DIO_vSetInterruptEnable( DIO_tenPinName enPin, bool boInterruptEnable );
void DIO_vSetInterruptEdge( DIO_tenPinName enPin, DIO_tenInterruptEdgeSelect enEdgeSelect );

#endif /* DIOC1_H_ */
